home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / sources.arc / BUILDER.C next >
Encoding:
C/C++ Source or Header  |  1994-02-06  |  20.2 KB  |  698 lines

  1. /*
  2.   BUILDER!!!!!!!!
  3.  
  4.     . This program will allow the user to interactively create
  5.       any scene with a few template primitives. 
  6.     . Once a scene in created, the program will generate C
  7.       code for it.
  8.     . Hopefully this will take away the boredom of creating 
  9.       scenes via typing in Bl,FL,FF etc for EVERY room and 
  10.       for EVERY direction of the compass.
  11.  
  12.  
  13.                  Jeff Bilger, Monday 1:20 am 1-2?-94
  14.  
  15.  
  16.    THE LOGIC
  17.    ---------
  18.  
  19. o Each pic then has 7 fields, and each field can have one of 9
  20.   templates. If a field is 0 then it does not use any template.
  21.  
  22.   struct field_data
  23.    {
  24.     int Field1,
  25.         Field2,
  26.         Field3,
  27.         Field4,
  28.         Field5,
  29.         Field6,
  30.         Field7;
  31.    };
  32.  
  33.   struct pic
  34.    {
  35.     struct field_data N,S,E,W;    for each direction it has 7 fields
  36.                                     that'll define the view
  37.    };
  38.  
  39.  o The map is made up of a 2d array of struct pic
  40.    
  41.     struct pic map[y][x];
  42.  
  43.  
  44.  o To build the map.
  45.    
  46.    1. Create your 2d map array by assigning the fields.
  47.        map[x][y].NSEorW.Field1
  48.        ......... ...... ......
  49.        map[x][y].NSEorW.Field7
  50.    
  51.  o To create a picture.for room at  map[0][0] FACING North
  52.    
  53.    1. vrocopy the main template, which is a sky and ground, to the screen.
  54.    2. look at map[0][0].N.Field1 if !0 it tells which template to get.
  55.       vrocopy this to the correct xy loc on the screen.
  56.    3. Do # 2 for Fields 2-6.
  57.   
  58.  
  59. */
  60.  
  61.       /* uses ONLY fncts from there 'h' files*/
  62. #include <gemdefs.h>       /* that it needs. Smart compiler */
  63. #include <osbind.h>
  64. #include <stdio.h>
  65. #include <strings.h>
  66. #include <linea.h>
  67. #define pos_rnd(t) Random()%(t)   /*returns a number from 0 to (t-1) */
  68.  
  69. int pts[4][2] = { 
  70.     320, 050,
  71.     120, 150,
  72.     520, 150,
  73.     320, 050
  74. };
  75. lineaport *theport;              /* a line identifier */
  76.  
  77. char *screen;    
  78.                      
  79. /* define our templates */
  80. #define CL  1
  81. #define CR  2
  82. #define CF1 3
  83. #define CF2 4
  84. #define ML  5
  85. #define MR  6
  86. #define MF  7
  87. #define FL  8
  88. #define FL_SPECIAL  9       /*  FL with a FF wall */
  89. #define FR  10
  90. #define FR_SPECIAL 11       /*  Fr w/ A FF wall */
  91. #define FF  12
  92. #define EMPTY 0
  93.  
  94. /* and our regions */
  95. #define R1  100
  96. #define R2  101
  97. #define R3  102
  98. #define R4  103
  99. #define R5  104
  100. #define R6  105
  101. #define R7  106
  102.  
  103. #define EXIT 200
  104. #define NEXT 201
  105. #define OK   202
  106.  
  107. int template_chosen,
  108.     region_chosen,
  109.     choice_chosen,
  110.     room,count ; 
  111. char string[80];
  112. unsigned form[37];
  113.  
  114. char pix1[] = "builder.pc1";
  115. char dir;
  116. int handle;
  117. int filehandle,i;
  118. int newpal[16],savepal[16];
  119. char     temp_[32000],                     /* Temp buffer where file is read in    */
  120.          *hld,
  121.          *iff_in, *iff_out;                  /* Pointers for DEGAS unpack() routine    */
  122. int contrl[12];
  123. int intin[256],  ptsin[256];
  124. int intout[256], ptsout[256];
  125. int rect1[] ={1,102,119,1};
  126.  
  127. FILE *ofp;   /* out file ptr */
  128.  
  129. main()
  130.  
  131. {
  132.     MFDB    theMFDB;    /*  Screen definition structure  */
  133.     MFDB    tempMFDB;
  134.     int status,Field;
  135.     char *scr1;
  136.     int pxyarray[8];      /* for vrocopyfm */
  137.     long hold_addr;
  138.    int x,y,template;
  139.    int ch,cw,dummy;
  140.    char com;
  141.    int count=0;   
  142.  
  143.   /* start up params */
  144.   printf("Start at which room #:");
  145.   scanf("%d",&room);
  146.        
  147.  
  148.  
  149.    theport = a_init();            /* invoke a line driver */
  150.  
  151.    x =0; y=0;
  152.    dir = 'N';
  153.     tempMFDB.fd_w    = theMFDB.fd_w ; /* 320 pixels wide*/
  154.     tempMFDB.fd_h       = theMFDB.fd_h ; /*200 pixels high */
  155.     tempMFDB.fd_wdwidth = theMFDB.fd_wdwidth ; /*16 words wide*/
  156.     tempMFDB.fd_stand = theMFDB.fd_stand ; /* raster coords.*/
  157.     tempMFDB.fd_nplanes = theMFDB.fd_nplanes; /*low rez has 4 planes */
  158.     
  159.  
  160.     appl_init();
  161.     handle = open_workstation(&theMFDB);  /*set up screen MFDB */
  162.  
  163.   
  164.    ofp = fopen("roomrec.dat","a");
  165.      
  166.  
  167.    vst_height(handle, 4, &dummy, &dummy, &cw, &ch);
  168.  
  169.    scr1 = malloc(32768+256);  /*allocate memory for 2nd screen */
  170.     if ((long) scr1 & 0xff)
  171.       scr1 = scr1 + (0x100 - (long)scr1 & 0xff);
  172.       
  173. read_stuff(pix1,scr1,1); /*templates*/        /* read back screen into memory */
  174.  
  175.  
  176. /* find screen base */
  177. screen = (char *)Physbase(); 
  178. Setscreen(scr1,scr1,-1);
  179.  
  180. theMFDB.fd_addr = (long) scr1;    /* set destination to be BACK screen*/
  181. tempMFDB.fd_addr = (long) scr1;
  182. Setpalette(newpal);        /* tel sys to use these colors! */
  183.  
  184.  
  185. graf_mouse(3,form);
  186.  
  187.  
  188. template_chosen = 0;
  189. region_chosen = 0;
  190. choice_chosen = 0;
  191. count = 0;  /* when count = 7, then we have created a full picture */
  192.  
  193.  while( Field != EXIT )
  194. {
  195.    count++;  /* when count == 7  reset to 0,
  196.                                  increment direction,
  197.                                     if dir = W set dir = N and room++
  198.              */
  199.  
  200.   
  201.    sprintf(string,"%c",dir);  /* convert char to string! */
  202.    v_gtext(handle,268,169,string);   /* show the direction */
  203.    sprintf(string,"%d",room);  
  204.    v_gtext(handle,268,160,string); /* show the room you're in */
  205.    v_gtext(handle,1,160,"Select a template and");
  206.    v_gtext(handle,1,167,"press left button.");
  207.   do                   /* do until you pick a template */
  208.    {
  209.     vq_mouse(handle,&status,&x,&y);
  210.       if(status & 0x1) Field=pick_template(x,y);       /* if left button pressed */
  211.    }while(!template_chosen);                     /* choose template */
  212.     
  213. template = Field;  /* save template type */
  214. template_chosen = 0;     /* reset this to 0 */
  215. print_template_chosen(Field,pxyarray); /* print which template was picked
  216.                                           and set pxyarrat for source     */
  217.  
  218.    v_gtext(handle,1,160,"Select a REGION and  ");
  219.    v_gtext(handle,1,167,"press left button.");
  220.                   /* now lets pic a destination region */
  221.   do 
  222.    {
  223.     vq_mouse(handle,&status,&x,&y);
  224.       if(status & 0x1) Field=pick_region(x,y); /* if left button pressed */
  225.    }while(!region_chosen);                     /* choose region */
  226.  
  227.   region_chosen = 0;     /* reset this to 0 */
  228.  print_region_chosen(Field,pxyarray,template); /* print which template was picked
  229.                                           and set pxyarrat for source     */
  230.  
  231. a_hidemouse();
  232.  copytemplates(&theMFDB,pxyarray);  /* copy the thing! */
  233. a_showmouse();
  234.   
  235.                                     /* Given Field = region and
  236.                                        template = template chosen
  237.                                        dir = direction
  238.                                        room = room #
  239.                                        CREATE a 'roomrec' entry */
  240.  create_roomrec(Field,template,dir,room);
  241.  
  242. /*
  243.   v_gtext(handle,1,160,"Press OK or NEXT     ");
  244.   v_gtext(handle,1,167,"press left button."); 
  245. */
  246.  
  247.            /* check for either ok,Next or done 
  248.  do 
  249.    {
  250.     vq_mouse(handle,&status,&x,&y);
  251.       if(status & 0x1) Field=pick_choice(x,y);  
  252.    }while(!choice_chosen);                    
  253.   choice_chosen = 0;     
  254.  process_choice(Field);  
  255. */
  256.  
  257.  
  258. /*
  259.  v_gtext(handle,1,160,"                     ");
  260.  v_gtext(handle,1,167,"                     ");
  261. */
  262. if( Bconstat(2) ) Field = EXIT;  /* press a key...we quit! */
  263.  
  264. v_gtext(handle,268,178,"    ");
  265. v_gtext(handle,268,187,"  ");
  266.  
  267.    if(count == 7)
  268.        {
  269.          vsf_color(handle,0);
  270.          vr_recfl(handle,rect1);                 /* clear out regions*/
  271.         count = 0;
  272.         switch(dir)
  273.          {
  274.            case 'N': dir = 'S'; break;
  275.            case 'S': dir = 'E'; break;
  276.            case 'E': dir = 'W'; break;
  277.            case 'W': dir = 'N'; room++; break;
  278.          }
  279.        }
  280.  
  281.  
  282.   }
  283.  
  284.     v_clsvwk(handle);
  285.     appl_exit();
  286.  
  287. }                      /* end of program */
  288.  
  289.  
  290.  
  291. /***************************************************************/
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298. /***********************************************/
  299. /* creates an entry in the roomrec[room].dir.Field */
  300.  
  301. create_roomrec(Field,template,dir,room)
  302. int Field,template,room;
  303. char dir;
  304. {
  305.  
  306.  
  307.  if( Field == R1)
  308.   {
  309.     fprintf(ofp,"/********************************************/\n");
  310.     sprintf(string,"roomrec[%d].%c.Field1=%d\n",room,dir,template);
  311.     fprintf(ofp,string);
  312.   }
  313.  if( Field == R2)
  314.   {
  315.     sprintf(string,"roomrec[%d].%c.Field2=%d\n",room,dir,template);
  316.     fprintf(ofp,string);
  317.   }
  318.  if( Field == R3)
  319.   {
  320.     sprintf(string,"roomrec[%d].%c.Field3=%d\n",room,dir,template);
  321.     fprintf(ofp,string);
  322.  
  323.   }
  324.  if( Field == R4)
  325.   {
  326.     sprintf(string,"roomrec[%d].%c.Field4=%d\n",room,dir,template);
  327.     fprintf(ofp,string);
  328.  
  329.   }
  330. if( Field == R5)
  331.   {
  332.     sprintf(string,"roomrec[%d].%c.Field5=%d\n",room,dir,template);
  333.     fprintf(ofp,string);
  334.  
  335.   }
  336. if( Field == R6)
  337.   {
  338.     sprintf(string,"roomrec[%d].%c.Field6=%d\n",room,dir,template);
  339.     fprintf(ofp,string);
  340.   }
  341. if( Field == R7)
  342.   {
  343.     sprintf(string,"roomrec[%d].%c.Field7=%d\n",room,dir,template);
  344.     fprintf(ofp,string);
  345.     fprintf(ofp,"/********************************************/\n\n");
  346.   }
  347.  
  348.  
  349.  
  350. }
  351. /***********************************************/
  352. process_choice(field)
  353. int field;
  354. {
  355.   if (field == EXIT) { }
  356.   if (field == NEXT) { vsf_color(handle,0);
  357.                        vr_recfl(handle,rect1); /* clear out regions*/
  358.                        if(dir == 'N') {dir = 'S'; return ; }
  359.                        if(dir == 'S') {dir = 'E';return ; }
  360.                        if(dir == 'E') {dir = 'W';return ; }
  361.                        if(dir == 'W') {dir = 'N'; room++; return ; }
  362.                      }
  363.  
  364.   if (field == OK)   { }
  365.                        
  366. }
  367. /*************************************************/
  368. copytemplates(mf,pxyarray)  /* copy the thing! */
  369. MFDB *mf;
  370. int pxyarray[];
  371. {
  372.  
  373. vro_cpyfm(handle,3,pxyarray,mf,mf);  /* copy it */
  374.  
  375. }
  376. /***********************************/
  377. /*
  378.    Choose which choice chosen, 
  379.    this will  set 
  380.    choice_chosen = 1 if a valid choice was picked
  381. */
  382. int pick_choice( x,y )
  383. int x,y;
  384.  
  385. {
  386.  
  387.   choice_chosen = 1;          /* set it valid */
  388.  
  389.   if(y >119  && y<142 )        /* in Y range of choices */ 
  390.    {
  391.     if( x > 173 && x < 222 ) return EXIT;
  392.     if( x > 230 && x < 272 ) return NEXT;
  393.     if( x > 279 && x < 319 ) return OK;
  394.    }
  395.  
  396.           /* if we get here, a valid choice was NOT found
  397.               so set CHOICE_chosen = 0 */
  398.   choice_chosen = 0;
  399.   return(0);  
  400.   
  401. }
  402. /***********************************/
  403. /*
  404.    Choose which template chosen, 
  405.    this will print WHICH template was chosen and set 
  406.    template_chosen = 1 if a valid template was picked
  407. */
  408. int pick_template( x,y )
  409. int x,y;
  410.  
  411. {
  412.  
  413.   template_chosen = 1;          /* set it valid */
  414.  
  415.   if(y > 0 && y<103 )        /* in Y range of templates */ 
  416.    {
  417.     if( x > 146 && x < 163 ) return FF;
  418.     if( x > 163 && x < 180 ) return CL;
  419.     if( x > 180 && x < 197 ) return ML;
  420.     if( x > 204 && x < 212 ) return FL_SPECIAL;
  421.     if( x > 212 && x < 220 ) return FR_SPECIAL;
  422.     if( x > 197 && x < 213 ) return FL;
  423.     if( x > 213 && x < 230 ) return FR;
  424.     
  425.     if( x > 231 && x < 247 ) return MR;
  426.     if( x > 247 && x < 264 ) return CR;
  427.     if( x > 264 && x < 281 ) return CF1;
  428.     if( x > 281 && x < 298 ) return CF2;
  429.     if( x > 298 && x < 315 ) return MF;
  430.     if( x > 124 && x < 142 ) return EMPTY;
  431.     
  432.    }
  433.  
  434.           /* if we get here, a valid choice was NOT found
  435.               so set template_chosen = 0 */
  436.   template_chosen = 0;
  437.   return(0);  
  438.   
  439. }
  440. /********************************************************/
  441. /* print which template was chosen and set the pxyarray
  442.    for the source */
  443.  
  444. print_template_chosen(Field,pxyarray)
  445. int Field,
  446.     pxyarray[];
  447.  
  448. {
  449.  
  450.  switch(Field)
  451.     {
  452.      case CL: pxyarray[0] = 163; pxyarray[1] = 1; pxyarray[2] = 179; pxyarray[3] = 102; v_gtext(handle,268,178,"CL"); break;
  453.      case ML: pxyarray[0] = 180; pxyarray[1] = 1; pxyarray[2] = 196; pxyarray[3] =102; v_gtext(handle,268,178,"ML"); break;
  454.      case FL: pxyarray[0] = 197; pxyarray[1] = 1; pxyarray[2] = 205; pxyarray[3] =102; v_gtext(handle,268,178,"FL"); break;
  455.      case FL_SPECIAL: pxyarray[0] = 197; pxyarray[1] = 1; pxyarray[2] = 213; pxyarray[3] =102; v_gtext(handle,268,178,"FL Sp"); break;
  456.      case CF1: pxyarray[0] = 265; pxyarray[1] = 1; pxyarray[2] = 281; pxyarray[3] =102; v_gtext(handle,268,178,"CF1"); break;
  457.      case CF2: pxyarray[0] = 282; pxyarray[1] = 1; pxyarray[2] = 298; pxyarray[3] =102; v_gtext(handle,268,178,"CF2"); break;
  458.      case MF: pxyarray[0] = 299; pxyarray[1] = 1; pxyarray[2] = 315; pxyarray[3] =102; v_gtext(handle,268,178,"MF"); break;
  459.      case FF: pxyarray[0] = 146; pxyarray[1] = 1; pxyarray[2] = 162; pxyarray[3] = 102; v_gtext(handle,268,178,"FF"); break;
  460.      case CR: pxyarray[0] = 248; pxyarray[1] = 1; pxyarray[2] = 264; pxyarray[3] = 102; v_gtext(handle,268,178,"CR"); break;
  461.      case MR: pxyarray[0] = 231; pxyarray[1] = 1; pxyarray[2] = 247; pxyarray[3] = 102; v_gtext(handle,268,178,"MR"); break;
  462.      case FR: pxyarray[0] = 222; pxyarray[1] = 1; pxyarray[2] = 230; pxyarray[3] = 102; v_gtext(handle,268,178,"FR"); break;
  463.      case FR_SPECIAL: pxyarray[0] = 214; pxyarray[1] = 1; pxyarray[2] = 230; pxyarray[3] = 102; v_gtext(handle,268,178,"FR Sp"); break;
  464.      case EMPTY: pxyarray[0] = 125; pxyarray[1] = 2; pxyarray[2] = 141; pxyarray[3] = 103; v_gtext(handle,268,178,"EMPTY"); break;
  465. break;
  466.  
  467.     }
  468.  
  469.  
  470. }
  471. /********************************************************/
  472. /***********************************/
  473. /*
  474.    Choose which region chosen, 
  475.    sets  
  476.    region_chosen = 1 if a valid region was picked
  477. */
  478. int pick_region( x,y )
  479. int x,y;
  480.  
  481. {
  482.  
  483.   region_chosen = 1;          /* set it valid */
  484.  
  485.   if(y > 0 && y<103 )        /* in Y range of regions */ 
  486.    {
  487.     if( x > 0 && x < 18 ) return R1;
  488.     if( x > 17 && x < 35 ) return R2;
  489.     if( x > 34 && x < 52 ) return R3;
  490.     if( x > 51 && x < 69 ) return R4;
  491.     if( x > 68 && x < 86 ) return R5;
  492.     if( x > 87 && x < 103 ) return R6;
  493.     if( x > 102 && x < 120 ) return R7;
  494.     }
  495.  
  496.           /* if we get here, a valid choice was NOT found
  497.               so set REGION_chosen = 0 */
  498.   region_chosen = 0;
  499.   return(0);  
  500.   
  501. }
  502. /********************************************************/
  503. /* print which region was chosen and set the pxyarray
  504.    for the dest */
  505.  
  506. print_region_chosen(Field,pxyarray,template)
  507. int Field,
  508.     pxyarray[],
  509.     template;
  510.  
  511. {
  512.  
  513.  switch(Field)
  514.     {
  515.      case R1: pxyarray[4] = 1; pxyarray[5]   = 1; pxyarray[6] = 17; pxyarray[7] = 102; v_gtext(handle,268,187,"R1"); break;
  516.      case R2: pxyarray[4] = 18; pxyarray[5]  = 1; pxyarray[6] = 34; pxyarray[7] =102; v_gtext(handle,268,187,"R2"); break;
  517.      case R3: pxyarray[4] = 35; pxyarray[5]  = 1; pxyarray[6] = 51; pxyarray[7] =102; v_gtext(handle,268,187,"R3"); break;
  518.      case R4: pxyarray[4] = 52; pxyarray[5]  = 1; pxyarray[6] = 68; pxyarray[7] =102; v_gtext(handle,268,187,"R4"); break;
  519.      case R5: pxyarray[4] = 69; pxyarray[5]  = 1; pxyarray[6] = 85; pxyarray[7] =102; v_gtext(handle,268,187,"R5"); break;
  520.      case R6: pxyarray[4] = 86; pxyarray[5]  = 1; pxyarray[6] = 102; pxyarray[7] =102; v_gtext(handle,268,187,"R6"); break;
  521.      case R7: pxyarray[4] = 103; pxyarray[5] = 1; pxyarray[6] = 119; pxyarray[7] =102; v_gtext(handle,268,187,"R7"); break;
  522.     }
  523.  
  524.   /* for display purposes only */
  525. if(template == FL) {
  526.             pxyarray[4] = 35; pxyarray[5]  = 1; pxyarray[6] = 43; pxyarray[7] =102;
  527.                    }
  528. if(template == FR) {
  529.             pxyarray[4] = 77; pxyarray[5]  = 1; pxyarray[6] = 85; pxyarray[7] =102;  
  530.                    }
  531.  
  532.  
  533. }
  534. /********************************************************/
  535.  
  536.  
  537.  
  538. /*********************************************************/
  539. /* load degas compressed pics */
  540.  
  541. /************************/
  542. read_stuff(hold,adrr,which)
  543. char hold[];
  544. register char *adrr;
  545. int which;  
  546. /* if which = 1 then store palette into newpal*/
  547. /* which is the main pal of the game. If = neg then store */
  548. /* into pal 4. the alternate pals of the game */
  549.  
  550. {
  551.  char buf[130];
  552.  int lines,m;
  553.  static int only_once = 1;
  554.  
  555. filehandle = Fopen(hold,0); 
  556.  
  557. if( only_once )        /* save the palette ONCE!!! */
  558. {
  559. for(i=0; i<16;i++)
  560.  savepal[i]=Setcolor(i,-1);
  561. only_once = 0;
  562. }
  563.  
  564. /* read header data */
  565. i=Fread(filehandle,2L,buf);
  566.  
  567.  
  568. /* read 16 words of palette data into newpal array */
  569.  
  570. i =Fread(filehandle,32L,newpal);
  571.  
  572.  
  573.  
  574.  
  575. i=Fread(filehandle,32000L,temp_);  /* read image onto back screen*/
  576. /* Close file */
  577. Fclose(filehandle);
  578.      lines = 200;                     /* Low, med-res    */
  579.                  iff_in  = temp_;                /* iff_in pts to temp_buf*/
  580.                  iff_out = adrr;      /* iff_out pts to pic_buffer*/
  581.                   do        
  582.          unpack(0);                                      /* Unpack a line at a time */
  583.                   while (--lines); 
  584.  
  585.  
  586.  /*v_gtext(handle,1,5,"             ");*/
  587.        
  588. }
  589. /************************/
  590.  
  591. /***********************/
  592.  
  593. /*---------------------------------------------------------------------------*/
  594. /*                             |--------- DEGAS ---------|            */
  595. /*                              UNCOMPRESSED   COMPRESSED            */
  596. /*                 NEO  low med mono   low med mono     TINY    */
  597. /*    typ...        0     1   2   3     4   5   6     7        */
  598.  
  599. /* Unpacks a single scan line & updates iff_in & iff_out global pointers
  600.  
  601.                      /    byt ==  0 to  127  copy next [byt+1] bytes
  602. Unpack routine --if-<    byt == -1 to -127  copy next byte [-byt+1] times
  603.                      \    byt == 128         NO-OP                            */
  604.  
  605. unpack(rez)
  606. int     rez;
  607.  
  608. {
  609.     register char     *src_ptr, *dst_ptr,           /* ptrs to source/dest */
  610.               byt, cnt;                     /* byt holds the ACTUAL compressed data code(control byte ) */
  611.     register int      minus128 = -128, 
  612.               len;                          
  613.     char                 linbuf[320];                            /* Oversize just in case! */
  614.     int                      llen;
  615.  
  616.  
  617.     if (rez < 2)     len = 160;
  618.     else             len = 80;
  619.     llen = len;
  620.     src_ptr = iff_in;           /* iff_in is ptr to compressed data */
  621.     dst_ptr = &linbuf[0];       /* linbuf WILL hold an ENTIRE Uncompressed scan line. 4 bitplanes * 80 = 320 max! */ 
  622.  
  623.     while (len > 0)
  624.    {
  625.             byt = *src_ptr++;       /* get byte value at address scr_ptr, THEN inc scr_ptr+1 */
  626.             if (byt >= 0)           /* If ctrl code >= 0 then use the next x+1 bytes*/
  627.     {
  628.                  ++byt;                 /* inc byt +1 */
  629.                   do 
  630.        {
  631.                         *dst_ptr++ = *src_ptr++;  /* get byte value from address source, and inc the 2 ptrs */
  632.                         --len;                    /* one byte down.. */
  633.                    }
  634.          while (--byt);           /* do this byt TIMES (remember byt here = byt+1 */
  635.              }
  636.              else 
  637.        if (byt != minus128)       /* else if ctrl code NOT = -128*/
  638.          {                        /*Then use the next byte -x+1 times, (-x) cause x will be negative and - - = + */
  639.                       cnt = -byt + 1;         /* cnt = -x + 1 */
  640.                       byt = *src_ptr++;       /* byt = THE very next byte past the ctrl code(or ctrl byte! */
  641.                        do {
  642.                                *dst_ptr++ = byt;  /* store that byte */
  643.                                --len;         
  644.                           }
  645.                while (--cnt);    /* keep doing it cnt times */
  646.                   }
  647.         }
  648.  
  649.     ilbm_st(linbuf, iff_out, rez);   /* convert the format line */
  650.     iff_in = src_ptr;                                    /* Update global pointers */
  651.     iff_out += llen;
  652.  
  653. }                                /* end of module uncompress() */
  654.  
  655. /*---------------------------------------------------------------------------*/
  656.  
  657. ilbm_st(src_ptr, dst_ptr, rez)           /* Convert ILBM format line to ST format */
  658. int         *src_ptr, *dst_ptr, rez;
  659. {
  660.     int         x, *p0_ptr, *p1_ptr, *p2_ptr, *p3_ptr;
  661.  
  662.     if (rez==0) 
  663.  {                                                     /* Low-res */
  664.   
  665.         p0_ptr = src_ptr;
  666.         p1_ptr = src_ptr + 20;
  667.         p2_ptr = src_ptr + 40;
  668.         p3_ptr = src_ptr + 60;
  669.         for (x=0; x<20; ++x)
  670.   {
  671.                *dst_ptr++ = *p0_ptr++;
  672.                *dst_ptr++ = *p1_ptr++;
  673.                *dst_ptr++ = *p2_ptr++;
  674.                *dst_ptr++ = *p3_ptr++;
  675.           }
  676.     } 
  677.  else if (rez==1) 
  678.   {                                            /* Med-res */
  679.            p0_ptr = src_ptr;
  680.            p1_ptr = src_ptr + 40;
  681.            for (x=0; x<40; ++x)
  682.     {
  683.                  *dst_ptr++ = *p0_ptr++;
  684.                  *dst_ptr++ = *p1_ptr++;
  685.             }
  686.     }
  687.     else 
  688.      {                                                   /* Monochrome */
  689.               for (x=0; x<40; ++x)
  690.                   *dst_ptr++ = *src_ptr++;
  691.          }
  692.  
  693.  }
  694. /*---------------------------------------------------------------------------*/
  695.  
  696.  
  697.  
  698.